<style>
.progresscls{height:24px;overflow:hidden;line-height:24px;border:0px #eeeeee solid; position:relative;;width:100%;background-color:#f1f1f1;margin-top:3px}
.progressclssse{background-color:#B0D6FC;height:24px;overflow:hidden;width:5%;position:absolute;z-index:0;left:0px;top:0px}
.progressclstext{font-size:10px;color:#0556A8;height:24px;overflow:hidden;line-height:24px;text-align:left;position:absolute;z-index:1;left:5px;top:0px}
.workheader span{float:left;display:block;padding:0px 10px; border-right:1px #dddddd solid;cursor:pointer;}
.workheader span:active{background:#e1e1e1}
</style>
<script type="text/javascript">
yingyonginit = function(){
	c.init();
}
var c = {
	typeid:0,
	init:function(){
		c.getfile(0);
		c.upobj = $.rockupload({
			'inputfile' : 'wordupfile',
			onchange:function(a){
				c.onchange(a);
			},
			onprogress:function(a,bl){
				c.onprogress(a,bl);
			},
			onsuccess:function(a,str){
				c.onsuccess(a,str);
			}
		});
	},
	onchange:function(a){
		$('#progresscls_hehehehsss').remove();
		$('body').append('<div id="progresscls_hehehehsss" style="position:absolute;bottom:50px;" class="progresscls"><div id="progresscls_heheheh" class="progressclssse"></div><div class="progressclstext" id="progresstext_heheheh" >'+a.filename+','+a.filesizecn+'(0%)</div></div>');
	},
	onprogress:function(a,per){
		$('#progresscls_heheheh').css('width',''+per+'%');
		$('#progresstext_heheheh').html(''+a.filename+','+a.filesizecn+'('+per+'%)');
	},
	onsuccess:function(a,str){
		var f = js.decode(str);
		$('#progresstext_heheheh').html(''+a.filename+','+a.filesizecn+'，上传成功,保存中...');
		var fileid = f.id;
		js.ajax('word','savefile',{typeid:c.typeid,fileid:fileid},function(a){
			$('#progresscls_hehehehsss').remove();
			js.msg('success',''+a.filename+'上传成功');
			a.fileid=a.id;
			$('#wordlisttable').append(c.showlist(a));
		},'none');
	},
	create:function(){
		js.wx.prompt('新建文件夹','请输入文件夹名称：',function(text){
			if(!text){js.msg('msg','没有输入文件夹名称');return;}
			js.ajax('word','createfolder',{name:text,typeid:c.typeid},function(a){
				c.createshow(a);
			});
		});
	},
	createshow:function(a){
		$('#wordlisttable').append(this.showlist(a));
	},
	up:function(){
		c.upobj.click();
	},
	
	getfile:function(pid,slx){
		this.typeid = pid;if(!slx)slx='';
		if(pid==0)this.movedata=false;
		this.ssslx = slx;
		js.ajax('word','getfile',{typeid:pid,slx:slx},function(a){
			c.data=[];
			c.showdata(a);
		},'mode');
	},
	showdata:function(a){
		var i,len=a.length,s;
		s='<table id="wordlisttable" style="width:100%; background-color:white">';
		for(i=0;i<len;i++){
			s+=c.showlist(a[i]);
		}
		s+='</table>';
		$('#mainbody_show').html(s);
	},
	showlist:function(d){
		if(!d.name)d.name=d.filename;
		if(!d.id)d.id=d.fileid;
		if(!d.fileext)d.fileext='folder';
		var oi = this.data.push(d),s1='';
		var s='';
		s+='<tr style="height:60px;border-top:1px #f1f1f1 solid" id="'+d.fileext+'_'+d.id+'" onclick="c.clicksse('+oi+',event,this)" >';
		s1='<div id="filename_'+oi+'">'+d.name+'</div>';
		if(d.fileid){
			s1+='<div style="font-size:12px;color:#888888">大小：'+d.filesizecn+'';
			if(!isempt(d.shate))s1+='，共享给：'+d.shate+'';
			s1+='</div>';
		}
		if(d.fileext=='folder'){
			s+='<td align="center" width="40"><img src="images/folder.png" height="24" width="24"></td><td>'+s1+'</td>';
		}else{
			var slx = d.fileext;
			if(js.fileall.indexOf(','+slx+',')<0)slx='wz';
			s+='<td align="center" width="40"><img src="web/images/fileicons/'+slx+'.gif" height="16" width="16"></td><td>'+s1+'</td>';
		}
		s+='</tr>';
		return s;
	},
	chentcolor:function(oi,e,o1){
		if(this._olodwet)$(this._olodwet).css('background','');
		$(o1).css('background','#f3f3f3');
		this._olodwet = o1;
	},
	clicksse:function(oi,e,o1){
		this.chentcolor(oi,e,o1);
		var d = this.data[oi-1];
		this.tempoi = oi;
		this.tempda = d;
		var a = [{name:(d.fileext=='folder')?'打开':'下载',lx:0}];
		if(!this.ssslx){
			a.push({name:'重命名',lx:1});
			if(d.fileext=='folder'){
				if(this.movedata)a.push({name:'['+this.movedata.name+']移动到这',lx:3});
			}else{
				a.push({name:'移动',lx:2});
			}
			a.push({name:'删除',lx:4});
		}
		if(d.fileext!='folder'){
			//a.push({name:'共享给...',lx:5});
			//a.push({name:'转发给...',lx:6});
		}
		js.showmenu({data:a,onclick:function(d){c.clickmenuss(d)}});
	},
	clickmenuss:function(d){
		var lx=d.lx;
		if(lx==0)this.celdblckc(this.tempoi);
		if(lx==1)this.cmmr();
		if(lx==2)this.movesss();
		if(lx==3)this.moveokzh();
		if(lx==4)this.delfload();
		if(lx==5)this.fenxiang();
		if(lx==6)this.zhuanfagei();
	},
	celdblckc:function(oi){
		var d = this.data[oi-1];
		if(d.fileext=='folder'){
			var s = '<span onclick="c.clickheadeer('+d.id+', this)">'+d.name+'&gt;</span>';
			$('#workheader').append(s);
			this.getfile(d.id);
		}else{
			if(js.isimg(d.fileext)){
				$.imgview({url:apiurl+d.filepath,ismobile:1});
			}else{
				js.downshow(d.fileid);
			}
		}
	},
	clickheadeer:function(pid,o1){
		var as = $('#workheader span');
		var rb = false;
		for(var i=0;i<as.length;i++){
			if(rb)$(as[i]).remove();
			if(o1==as[i])rb=true;
		}
		c.getfile(pid);
	},
	cmmr:function(){
		js.wx.prompt('重命名','请输入新的名称：',function(text){
			if(!text){js.msg('msg','没有输入新的名称');return;}
			if(c.tempda.name==text)return;
			c.data[c.tempoi-1].name=text;
			$('#filename_'+c.tempoi+'').html(text);
			c.cmmrssok(text);
		},this.tempda.name);
	},
	cmmrssok:function(txt){
		var d={id:this.tempda.id,type:this.tempda.fileext,name:jm.base64encode(txt)};
		js.ajax('word','rename',d,function(a){},'none');
	},
	movesss:function(){
		this.movedata = this.tempda;
	},
	moveokzh:function(){
		var d = this.movedata;
		if(d.typeid==this.tempda.id)return;
		$('#'+d.fileext+'_'+d.id+'').remove();
		this.movedata=false;
		js.ajax('word','movefile',{type:d.fileext,id:d.id,tid:this.tempda.id},function(a){
			js.msg('success','移动成功');
		});
	},
	delfload:function(){
		js.wx.confirm('确定要删除吗？',function(lx){
			if(lx=='yes')c.delfloadok();
		});
	},
	delfloadok:function(){
		var d = this.tempda;
		this.movedata=false;
		js.ajax('word','delfile',{type:d.fileext,id:d.id},function(a){
			$('#'+d.fileext+'_'+d.id+'').remove();
			js.msg('success','删除成功');
		});
	},
	wfenxx:function(lx){
		this.getfile(this.typeid,lx);
	}
};
yy.clickevent=function(d){
	if(d.url=='create')c.create();
	if(d.url=='up')c.up();
	if(d.url=='shate')c.wfenxx('wfx');	
	if(d.url=='fxgw')c.wfenxx('fxgw');	
}
</script>
<div class="workheader" id="workheader" style="line-height:50px;height:50px; background-color:#ffffff;overflow:hidden"><span onclick="c.clickheadeer(0, this)">我的文档&gt;</span></div>
<div id="mainbody_show"></div>